//
//  RMMDuiHuanYouHuiQuanView.m
//  Romomo
//
//  Created by puman on 2017/3/8.
//  Copyright © 2017年 mazegong. All rights reserved.
//

#import "RMMDuiHuanYouHuiQuanView.h"

@implementation RMMDuiHuanYouHuiQuanView
- (instancetype)initWithFrame:(CGRect)frame{
    if ([super initWithFrame:frame]) {
        self.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.2];
        UIView *view = [[UIView alloc] initWithFrame:CGRectMake(30, 60, self.width - 60, 200)];
        view.backgroundColor = [UIColor whiteColor];
        [self addSubview:view];
        
        UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, view.width, 40)];
        label.text = @"兑换优惠券";
        label.textAlignment = NSTextAlignmentCenter;
        label.font = kBFont(16);
        [view addSubview:label];
        
        UIView *lineView = [[UIView alloc] initWithFrame:CGRectMake(0, label.bottom, view.width, 1)];
        lineView.backgroundColor = kCColor;
        [view addSubview:lineView];

        
        _textF = [[UITextField alloc] initWithFrame:CGRectMake(kRow, lineView.bottom + kRow, view.width - kMaric, 40)];
        _textF.borderStyle = UITextBorderStyleRoundedRect;
        _textF.textAlignment = NSTextAlignmentCenter;
        _textF.font = kBFont(16);
        _textF.clearButtonMode = UITextFieldViewModeWhileEditing;
        _textF.placeholder = @"请输入兑换编码";
        [view addSubview:_textF];
        
        for (int i = 0; i < 2; i++) {
            UIButton *button = [UIButton buttonWithType:(UIButtonTypeCustom)];
            button.layer.masksToBounds = YES;
            button.layer.cornerRadius = 3;
            button.frame = CGRectMake(10, _textF.bottom + 10 + 50 * i, view.width - 20, 40);
            if (i == 0) {
                _confirmBut = button;
                [button setTitle:@"确定兑换" forState:(UIControlStateNormal)];
                button.userInteractionEnabled = NO;
                button.backgroundColor = RGBA(237, 238, 239, 1);
                [button setTitleColor:RGBA(212, 213, 214, 1) forState:(UIControlStateNormal)];
            } else {
                _cancelBut = button;
                [button setTitle:@"取消兑换" forState:(UIControlStateNormal)];
                [button setTitleColor:COLORFROMCODE(0x2B2B2B, 1) forState:(UIControlStateNormal)];
                button.backgroundColor = COLORFROMCODE(0x9B9B9B, 1);
            }
            [view addSubview:button];
        }
    }
    return self;
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
